<html>
<head>
<title>XmlHttpRequest open injected header test \r\n in async flag sync check only</title>
<script type="text/javascript" src="/shared/scripts/header.js"></script>
<script type="text/javascript" src="/shared/scripts/testcase.js"></script>
<script type="text/javascript">
if (window.addEventListener) {
	window.addEventListener('load', f, false);
} else if (window.attachEvent) {
	window.attachEvent('onload', f);
} else {
	window.onload = f;
}
// this became a little more complicated than I'd like to see in a testcase...
function f() {
	var header = new Headers();
	var result = 'not found';
	var tc = new TestCase();
	tc.description = 'XmlHttpRequest open injected header test \r\n in async flag sync check only';
	tc.test_passed = 'true'; // always passed, only set to false if we find the header.
	tc.expected_result = 'not found';
	tc.result = 'not found';
	var injected_header = header.banned_header + ": " + header.banned_value;
	var xhr = get_xhr();
	tc.input = "xhr.open('GET','/testcases/headertests/showRequest?', '"+injected_header+"')";

	// the sensible thing would be to cause an exception here.
	try {
		xhr.open('GET', '/testcases/headertests/showRequest?', injected_header);
	} catch(e) {	
		tc.output += 'Injecting (' + injected_header + ')into async flag caused an exception in xhr.open():'+tc.outputException(e);
		tc.saveTest(null);
		return;
	}
	try {
		xhr.send();
		if (xhr.readyState == 4) {
			var ret = header.checkExists(xhr.responseText, tc);
			if (ret != 0) {
				tc.result = 'found';
				tc.test_passed = 'false';
			}
			tc.output += '\r\nraw data:\r\n' + xhr.responseText;
		}
	} catch(e) {
		tc.output += 'Injecting (' + injected_header + ') caused an exception in xhr.send():'+tc.outputException(e);
	}
	tc.saveTest(null);
}
</script>
</head>
<body></body>
</html>